﻿(function() {
	$(function() {
		$('#TotalLevel').blur(function() {
			$('.levelPercentItems').html(renderLevelPercentItem(this.value));
		});
		$('#sumbitBut').click(function() {
			if (validateParam()) {
				$('form').submit();
			}
		});
	});

	function validateParam() {
		return true;
	}

	function renderLevelPercentItem(level) {
		var elStr = '';
		for (var i = 1; i <= level; i++) {
			elStr += levelPercentTemp.replace(/#level/g, i)
				.replace(/#index/g, i-1)
				.replace(/#item1/g, i)
				.replace(/#item2/g, '');
		}
		return elStr;
	}

	var levelPercentTemp = '<tr>\
					<td>#level级</td>\
					<td>\
						<input name="LevelPercent[#index].Item1" id="LevelPercent_#index__Item1" type="hidden" value="#item1">\
						<input name="LevelPercent[#index].Item2" id="LevelPercent_#index__Item2" type="text" value="#item2">%\
					</td>\
				</tr>';
})();